package com.fg.cloud.manager.service.product.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fg.cloud.common.PageUtils;
import com.fg.cloud.manager.entry.BaseEntity;
import com.fg.cloud.manager.entry.product.ProductUnitEntity;
import com.fg.cloud.manager.mapper.BaseMapper;
import com.fg.cloud.manager.mapper.product.ProductUnitMapper;
import com.fg.cloud.manager.service.BaseServiceImpl;
import com.fg.cloud.manager.service.product.ProductUnitService;

/**
 * @author liushengchao
 * @Description: 商品单位接口实现 
 * @date 2017年6月20日下午1:56:09
 *
 */
@Service
public class ProductUnitServiceImpl extends BaseServiceImpl implements ProductUnitService{
	
	@Autowired
	private ProductUnitMapper unitMapper ; 

	@Override
	protected <T extends BaseEntity> BaseMapper getBaseMapper() {
		return unitMapper;
	}

	@Override
	public void selectforPage(PageUtils<ProductUnitEntity> pageinfo) {
		long total = unitMapper.selectCount(pageinfo);
		pageinfo.setTotal(total);
		if (total > 0) {
			pageinfo.setData(unitMapper.selectforPage(pageinfo));
		} else {
			pageinfo.setData(new ArrayList<ProductUnitEntity>());
		}
	}

	@Override
	@Transactional
	public int deletes(Map<String, Object> condition) {
		return unitMapper.deletes(condition);
	}

	@Override
	public int findnum(ProductUnitEntity unitEntity) {
		return unitMapper.findnum(unitEntity);
	}

	@Override
	public List<ProductUnitEntity> findAll(Long facId) {
		return unitMapper.findAll(facId);
	}

	@Override
	public ProductUnitEntity findByName(Long facId, String unitName) {
		return unitMapper.findByName(facId, unitName);
	}

}
